﻿@{
    ViewBag.Title = "部门选择";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@section HeadIncluder 
{
    <link rel="stylesheet" type="text/css" href=@Url.Content("~/Scripts/skins/default.css")   />
}
<table>
    <tr>
        <td  class="text_s">公司</td>
        <td>
              @{
                    Html.RenderPartial("UCCompanySelectTree", (IList<FB.Providers.EmployeeInfo.Company>)ViewBag.CompanyList);
                } 
        </td>
    </tr>
    <tr>
        <td  class="text_s">部门</td>
        <td class="lable" id="deptConatainer">
            @{
                    Html.RenderPartial("UCDepartmentSelectTree", (IList<FB.Providers.EmployeeInfo.Department>)ViewBag.DepartmentList);
                } 
        </td>
    </tr>
</table>
<div class="ui_buttons" style="background: #d4e4f6; padding-right: 20px;">

    <input id="subbtn" type="button" value="确定" class="ui_state_highlight" />
    <input type="button" value="取消" onclick="cancel();" />
</div>
 
     <script src=@Url.Content("/Scripts/jquery.form.js") type="text/javascript"></script>
   <script   type="text/javascript">
       function GetDepartmentList() {
           var url = '@Url.Action("GetDeparmentList", "Form")' + '?CompanyID=' + $("#CompanyList").val();
            $.post(url, function (data) {
                $("#deptConatainer").html(data); 
            });
        }
       $(function () {
           GetDepartmentList();
           $("#CompanyList").bind("change", function () {
               GetDepartmentList();
           });
           $("#subbtn").click(function () {
               var deptID = $("#deparmentList").val();
               var deptName = $("#deparmentList").find("option:selected").text();
               var windowcallback = '@Request["windowcallback"]';
               if (windowcallback != "" && window.opener != undefined && window.opener != null) {
                   window.opener.AddDeptCallBack(deptID, deptName);
                   window.close();
               } else {
                   window.top.refresh(deptID, deptName);
                   window.top.oDG.close();
               } 
           });
       });
       function cancel() {
           if (window.opener != undefined && window.opener != null) {
               window.close();
           } else {
               window.top.oDG.close();
           }
       };
          </script>
